package com.zjj.learn.algorithmPlus.segment1.blockQueue;

/**
 * @author zjj_admin
 */
public class ThreadUnsafe {

    private  String[] array = new String[10];
    private int size = 0;
    private static Object object = new Object();


    public void offer(String val) {
        array[size] = val;
        size++;
    }

    @SuppressWarnings("all")
    public static void main(String[] args) throws InterruptedException {
        ThreadUnsafe queue = new ThreadUnsafe();
        Thread t1 = new Thread(() -> {
            queue.offer("e1");
        }, "t1");
        t1.start();

        synchronized (object){
            t1.wait();
        }
        new Thread(() -> {
            queue.offer("e2");
        }, "t2").start();
    }
}
